package com.rm.zeyou.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.github.pagehelper.PageInfo;
import com.rm.zeyou.entity.User;
import com.rm.zeyou.response.ApiRestResponse;
import com.rm.zeyou.service.SalesmanPayoutDetailService;
import com.rm.zeyou.util.login.LoginUtil;
import com.rm.zeyou.vo.request.SalesmanPayoutListVo;
import com.rm.zeyou.vo.request.SelectUserPayoutIndexVo;
import com.rm.zeyou.vo.response.ConfirmPayoutResponseVo;
import com.rm.zeyou.vo.response.SalesmanPayoutListResponseVo;
import com.rm.zeyou.vo.response.SelectUserPayoutIndexResponseVo;
import com.rm.zeyou.vo.response.UserPayoutVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 业务员提现记录表 前端控制器
 * </p>
 *
 * @author YanYang
 * @since 2025-03-12 15:55:08
 */
@Api(tags = "业务员提现相关")
@RestController
@RequestMapping("/api/salesmanPayoutDetail")
public class SalesmanPayoutDetailController {
    @Resource
    private SalesmanPayoutDetailService salesmanPayoutDetailService;
    @Resource
    private LoginUtil loginUtil;

    @ApiOperation("业务员提现页面")
    @PostMapping("selectSalesmanPayoutIndex")
    @SaCheckLogin(type = "user")
    public ApiRestResponse<SelectUserPayoutIndexResponseVo> selectSalesmanPayoutIndex(@RequestBody SelectUserPayoutIndexVo requestVo){
        User user = loginUtil.getUser();
        return salesmanPayoutDetailService.selectSalesmanPayoutIndex(user,requestVo);
    }


    @ApiOperation("业务员提现")
    @PostMapping("salesmanPayout")
    @SaCheckLogin(type = "user")
    public ApiRestResponse<Integer> salesmanPayout(@RequestBody UserPayoutVo requestVo){
        User user = loginUtil.getUser();
        return salesmanPayoutDetailService.salesmanPayout(user,requestVo);
    }

    @ApiOperation("业务员提现记录")
    @PostMapping("salesmanPayoutList")
    @SaCheckLogin(type = "user")
    public ApiRestResponse<PageInfo<SalesmanPayoutListResponseVo>> salesmanPayoutList(@RequestBody SalesmanPayoutListVo requestVo){
        User user = loginUtil.getUser();
        return salesmanPayoutDetailService.salesmanPayoutList(user,requestVo);
    }

    @ApiOperation("业务员确认提现列表")
    @PostMapping("salesmanConfirmPayout")
    @SaCheckLogin(type = "user")
    public ApiRestResponse<List<ConfirmPayoutResponseVo>> salesmanConfirmPayout() {
        User user = loginUtil.getUser();
        return salesmanPayoutDetailService.salesmanConfirmPayout(user);
    }

}
